<%@page import="study.itwill.team5.admin.AdminItem"%>
<%@page import="study.itwill.jsp.WebHandler"%>
<%@page import="study.itwill.team5.member.WishList"%>
<%@page import="study.itwill.team5.member.WishItem"%>
<%@page import="study.itwill.common.PatternChecker"%>
<%@page import="study.itwill.team5.house.House"%>
<%@page import="study.itwill.team5.house.HouseItem"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page session="true" %>
<%
   WebHandler web = new WebHandler(request, response, out);
   AdminItem loginInfo = (AdminItem)session.getAttribute("ADMIN_INFO");
   
   // 로그인 정보가 없을 경우 로그인 페이지로 이동
   if (loginInfo == null) {
	   web.goPage("/italia/login.jsp", "로그인이 필요합니다");
      return;
   }
%>
<%@ include file="../dbcon.jsp"%>
<%
	ArrayList<WishItem> list = (new WishList()).listWishList();

	if (list == null) {
		out.print("<script type='text/javascript> alert('데이터 조회에 실패했습니다. 잠시후 다시 시도해 주세요.'); history.back();</script>");
		return;
	}
%>
<!DOCTYPE html>
<html lang="ko">
  <head>
  	<%@ include file="../head.jsp" %>
  	   <!-- Javascript -->
    <script src="/italia/assets/js/jquery.js"></script>
    <script src="/italia/assets/js/bootstrap.min.js"></script>
  </head>
  <body>
 	 <%@ include file="../menu.jsp" %>
  <%DBHandler.disconnect();%>
    <!-- 웹 페이지 영역 -->
    <div class="container">
    	<div class="page-header clearfix">
	    	<h1 class="pull-left">나의 찜 목록</h1>
	    	<div class="pull-right" style="padding-top: 30px">
	    		<a href="addWishList.jsp" class="btn btn-info">추가하기</a>
    		</div>
	
			<div class="table-responsive">
				<table class="table table-striped table-hover">
					<thead>
						<tr class="warning">
							<th class="text-center">회원 일련번호</th>
							<th class="text-center">회원 이름</th>
							<th class="text-center">민박 일련번호</th>
							<th class="text-center">민박 이름</th>
							<th class="text-center">등록일</th>
							<th class="text-center"></th>
						</tr>
					</thead>
					<tbody>
						<%
							if (list.size() < 1) {
						%>
						<tr>
							<td colspan="5">
								<p class="text-center text-warning" style="height: 100px">
								저장된 데이터가 없습니다.</p>
							</td>
						</tr>
						<%
							} else {
							for (int i=0; i<list.size(); i++) {
								WishItem item = list.get(i);
						%>
						<tr class="text-center">
							<td><%=item.getMember_seq()%></td>
							<td><%=item.getUser_name()%></td>
							<td><%=item.getHouse_seq()%></td>
							<td><%=item.getName()%></td>
							<td><%=item.getReg_date()%></td>
							<td><a href="deleteWishListOk.jsp?member_seq=<%=item.getMember_seq()%>&house_seq=<%=item.getHouse_seq()%>"
									class="btn btn-danger" id="delete<%=item.getMember_seq()%><%=item.getHouse_seq()%>">삭제하기</a>
							<script type="text/javascript">
							 	// jquery main()
								$(function() {
									$("#delete<%=item.getMember_seq()%><%=item.getHouse_seq()%>").click(function() {
									// 사용자에게 물어본다.
							    		if (!confirm("정말 삭제하시겠습니까?")) {
							    			// "취소"를 선택한 경우 처리 중단
							    			return false;
							    		}
									});
								});
							  </script>
						</tr>
						<%
							} // end for
						} // end if
						%>
					</tbody>
				</table>
			</div>

    	</div>
    </div>
  </body>
</html>